﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Quizz.DataRepository.Models;
using Quizz.Service.Log;

namespace Quizz.QuizzProjectService
{
    public partial class QuizzProjectService
    {
        public LoginLog LoginLogGetById(long id)
        {
            using(var service = new LoginLogService())
            {
                return service.GetById(id);
            }
        }

        public LoginLog LoginLogGetBySessionId(string sessionId)
        {
            using(var service = new LoginLogService())
            {
                return service.GetBySessionId(sessionId);
            }
        }

        public void LoginLogInsert(LoginLog log)
        {
            using(var service = new LoginLogService())
            {
                service.Insert(log);
            }
        }

        public void LoginLogUpdate(LoginLog log)
        {
            using (var service = new LoginLogService())
            {
                service.Update(log);
            }
        }

        public void LoginLogDelete(long id)
        {
            using(var service = new LoginLogService())
            {
                service.Delete(id);
            }
        }

        public LoginLog LoginLogGetLastLogin(long userid)
        {
            using(var service = new LoginLogService())
            {
                return service.GetLastLogin(userid);
            }
        }

        public int LoginLogGetNumberOfLogin(DateTime date)
        {
            using(var service = new LoginLogService())
            {
                return service.GetNumberOfLogin(date);
            }
        }

        public IList<LoginLog> LoginLogGetLogs(DateTime fromDate, DateTime toDate)
        {
            using(var service = new LoginLogService())
            {
                return service.GetLoginLogs(fromDate, toDate).ToList();
            }
        }

        public IList<LoginLog> LoginLogGetUserLogs(long userId)
        {
            using(var service = new LoginLogService())
            {
                return service.GetLoginLogs(userId).ToList();
            }
        }
    }
}